package pt.iscte.dcti.pr.dbo;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Image {

	private String location;
	private int id;
	private String url;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getLocation() {

		try {
			ConnectDataBase dbcon = new ConnectDataBase();
			Connection con = dbcon.mySqlConnection();

			String query = "select url from imagem where id=2";

			Statement stmt = con.createStatement();
			ResultSet rs = stmt.executeQuery(query);

			while (rs.next()) {

				System.out.println(" --->" + rs.getString("url"));
				location = rs.getString("url");
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return location;
	}

}
